Self-assembly of nanoparticles